import { createStore } from 'vuex';

const admin: IAdmin = {
  t_admin_pk: undefined,
  admin_name: undefined,
  token: undefined,
  mobile: undefined,
  funList: [],
  funSet: [],
  pageURLs: [],
}

export default createStore({
  state: {
    admin
  },
  getters: {
  },
  mutations: {
    setAdmin(state, payload: IAdmin) {
      const pageURLs: string[] = [];
      if (payload.funList) {
        payload.funList.forEach((v: any) => {
          v.funs.forEach((v: any) => {
            if (v) {
              pageURLs.push(v.page_url);
            }
          })
        })
        payload.pageURLs = pageURLs;
      }
      state.admin = payload;
    },
  },
  actions: {
  },
  modules: {
  }
})
